const wx2my = require('../../../wx2my');
const Behavior = require('../../../Behavior');
var app = getApp();
Page({
  data: {},
  onLoad: function (e) {
    var a = this;
    a.setData({
      color: wx2my.getStorageSync("platform").color
    }), app.util.request({
      url: "entry/wxapp/orderdetails",
      data: {
        order_id: e.id
      },
      success: function (e) {
        console.log(e);
        var t = e.data;
        t.arrival_time = t.arrival_time.slice(5, 7) + "月" + t.arrival_time.slice(8, 10) + "日", t.departure_time = t.departure_time.slice(5, 7) + "月" + t.departure_time.slice(8, 10) + "日", t.time = app.ormatDate(t.time), a.setData({
          order_info: t
        });
      }
    }), wx2my.setNavigationBarColor({
      frontColor: '#000000',
      backgroundColor: '#ffffff'
    });
  },
  confirmorder: function (e) {
    var t = app.OpenId,
        a = this.data.order_info;
    app.util.request({
      url: "entry/wxapp/Pay",
      cachetime: "0",
      data: {
        openid: t,
        money: a.total_cost,
        order_id: a.id
      },
      success: function (e) {
        wx.requestPayment({
          timeStamp: e.data.timeStamp,
          nonceStr: e.data.nonceStr,
          package: e.data.package,
          signType: e.data.signType,
          paySign: e.data.paySign,
          success: function (e) {
            console.log("支付成功"), console.log(e), wx2my.navigateBack({
              delta: 1
            });
          },
          fail: function (e) {
            console.log("支付失败"), wx2my.showToast({
              title: "支付失败"
            });
          }
        });
      }
    });
  },
  order_more: function (e) {
    wx2my.navigateTo({
      url: "../hotel_list/hotel_info?hotel_id=" + this.data.order_info.seller_id
    });
  },
  see_more: function (e) {
    2 == wx2my.getStorageSync("platform").type ? wx2my.navigateTo({
      url: "../hotel_list/hotel_list"
    }) : wx2my.navigateTo({
      url: "../index/index"
    });
  },
  cancel_order: function (e) {
    var t = e.currentTarget.dataset.id,
        a = e.currentTarget.dataset.hb_id;
    console.log(a), app.util.request({
      url: "entry/wxapp/CancelOrder",
      data: {
        order_id: t,
        hb_id: a
      },
      success: function (e) {
        console.log(e), wx2my.showToast({
          title: "订单已取消"
        }), setTimeout(function () {
          wx2my.navigateBack({
            delta: 1
          });
        }, 1500);
      }
    });
  },
  apply: function (e) {
    var t = e.currentTarget.dataset.id;
    console.log(t), app.util.request({
      url: "entry/wxapp/ChangeOrder",
      data: {
        order_id: t,
        status: 5
      },
      success: function (e) {
        console.log(e), wx2my.showToast({
          title: "申请成功"
        }), setTimeout(function () {
          wx2my.navigateBack({
            delta: 1
          });
        }, 1500);
      }
    });
  },
  refuse: function (e) {
    var t = e.currentTarget.dataset.id;
    console.log(t), app.util.request({
      url: "entry/wxapp/ChangeOrder",
      data: {
        order_id: t,
        status: 8
      },
      success: function (e) {
        console.log(e), wx2my.showToast({
          title: "申请成功"
        }), setTimeout(function () {
          wx2my.navigateBack({
            delta: 1
          });
        }, 1500);
      }
    });
  },
  Refund: function (e) {
    var t = e.currentTarget.dataset.id;
    console.log(t), app.util.request({
      url: "entry/wxapp/Refund",
      data: {
        order_id: t
      },
      success: function (e) {
        console.log(e), wx2my.showToast({
          title: "申请成功"
        }), setTimeout(function () {
          wx2my.navigateBack({
            delta: 1
          });
        }, 1500);
      }
    });
  },
  YjRefund: function (e) {
    this.setData({
      YjRefund: !0
    });
  },
  refoned_money: function (e) {
    var t = this,
        a = t.data.order_info.yj_cost;
    e.detail.value <= a ? t.setData({
      refoned_money: e.detail.value
    }) : t.setData({
      refoned_money: a
    });
  },
  cancel: function (e) {
    this.setData({
      YjRefund: !1
    });
  },
  confirm: function (e) {
    var t = this,
        a = t.data.order_info.id,
        o = t.data.refoned_money;
    if (null == o) var n = t.data.order_indo.yj_cost;else n = o;
    app.util.request({
      url: "entry/wxapp/YjRefund",
      data: {
        order_id: a,
        money: n
      },
      success: function (e) {
        console.log(e), 1 == e.data ? (wx2my.showToast({
          title: "申请成功"
        }), t.setData({
          YjRefund: !1
        }), setTimeout(function () {
          wx2my.navigateBack({
            delta: 1
          });
        }, 1500)) : (wx2my.showToast({
          title: "退款失败"
        }), t.setData({
          YjRefund: !1
        }));
      }
    });
  },
  sele_address: function (e) {
    var o = this.data.order_info,
        n = o.coordinates.split(",");
    wx2my.getLocation({
      type: "gcj02",
      success: function (e) {
        var t = Number(n[0]),
            a = Number(n[1]);
        wx2my.openLocation({
          latitude: t,
          longitude: a,
          name: o.seller_name,
          address: o.seller_address
        });
      }
    });
  },
  go_eveluate: function (e) {
    wx2my.navigateTo({
      url: "evaluate?seller_id=" + this.data.order_info.seller_id + "&order_id=" + this.data.order_info.id
    });
  },
  onReady: function () {},
  onShow: function () {},
  onHide: function () {},
  onUnload: function () {},
  onPullDownRefresh: function () {},
  onReachBottom: function () {}
});